(function ({form,table,layer,laydate,tableIns,userid,formdata,url,contentType,ok,AjaxFn}) {

    form.render(),

    formdata = (function (data) {
        let date = AjaxFn(url+'selectByUserId',JSON.stringify({userid}),data);
        date.code!=200?(function () {
            layer.msg(date.msg,{icon: 5});
        })():'';
        return date;
    })({});

    (function () {/*{msg: "ok",code: "200",data:}*/
        formdata.code=="200" && !$.isEmptyObject(formdata.data)?(function () {
            form.val("formfilter", {
                "userid":formdata.data.userid,
                "username":formdata.data.username
            });
        })():'';
    })(),

    form.verify({
        custompassword:function (value, item) {
            if(value!=''){
                if (value.length<6){
                    $("#"+$(item).attr("data-p")).text("密码长度最小为6位")
                    return "密码长度最小为6位";
                }
                if(!/^[a-zA-Z0-9]+$/.test(value)){
                    return "密码只能以数字和字母组成";
                }
            }
        }
    }),

    form.on('submit(useradd)', function({elem,form,field}){
        formdata.data.newUserName=field.username.trim();
        formdata.data.newPassword=field.password.trim();
        let {msg,code} = AjaxFn(url+"updateUserByid",JSON.stringify(formdata.data),{});
        code==200?(function () {
            ok(msg,1);
        })():layer.msg(msg,{icon:4});
        return false;
    })


})({
    form: layui.form,
    table: layui.table,
    layer: layui.layer,
    laydate:layui.laydate,
    tableIns: '',
    formdata:{},
    userid:$("#userid").val(),
    b:0,
    url: "/evaluation/userInput/",
    contentType: 'application/json;charset=utf-8',
    ok:function(msg,icon){
        layui.layer.confirm(msg, {
            id: "ok",
            icon: icon,
            anim: 4,
            title: '提示',
            btn:['确定'],
            success: function (layero) {
                var btn = layero[0].getElementsByClassName('layui-layer-btn')[0].getElementsByTagName('A')[0];
                btn.href = 'javascript:void(0)';
                btn.focus();
            },
            yes: function(index, layero){
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            },
            end:function () {}
        });
    },
    AjaxFn:function (url,data,resource) {
        $.ajax({
            url,
            contentType:'application/json;charset=utf-8',
            type:'post',
            async:false,
            data,
            success:function(res) {
                resource = res;
            }
        });
        return resource;
    }
})